﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using BLL.Cms;
using Model.Cms;
namespace Com.Ompchina.Web.UIControl
{
    public partial class FocusBlock : System.Web.UI.UserControl
    {
        public string BlockLabel { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected string ScriptText() 
        {
            System.Text.StringBuilder repo = new System.Text.StringBuilder();
            repo.AppendFormat("var {0} =new PPTBox();", BlockLabel);
            repo.AppendFormat("{0}.width = 260;", BlockLabel);
            repo.AppendFormat("{0}.height = 150;", BlockLabel);
            repo.AppendFormat("{0}.autoplayer = 3;", BlockLabel);
            IList<BlockInfo> list = new BlockBLL().FrontListByTerm(false, 0, BlockLabel, 5);
            foreach (BlockInfo info in list)
                repo.AppendFormat("{0}.add({{\"url\":\"/{1}\",\"href\":\"{2}\",\"title\":\"{3}\"}});", BlockLabel
                    , info.Filepath, info.Link, info.BlockName);
            repo.AppendFormat("{0}.show();", BlockLabel);
            return repo.ToString();
        }
    }
}